#pragma once
#include <EGL/egl.h>  // EGL支持
#include <GLES3/gl3.h>
#include <android/log.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>  // ANativeWindow_fromSurface
#include <jni.h>

#include "include/player_state.h"
#include "include/state_manager.h"
#include "jni/jni_callback.h"
#include "jni/jni_help.h"

namespace codec {
class NativeCodecHandler {
 private:
  std::string TAG_ = "NativeCodecHandler";
  std::unique_ptr<StateManager> stateManager = std::make_unique<StateManager>();

 public:
  NativeCodecHandler() = default;
  NativeCodecHandler &operator=(const NativeCodecHandler &) = delete;
  ~NativeCodecHandler();
  void setDataSource(int fd);
  void prepare(ANativeWindow *window, const std::string &vertexCode,
               const std::string &fragmentCode);
  void start();
  void pause();
  void resume();
  void stop();
  void seekTo(float position);
  void setCallback(jobject callback);
  void ChangeSurface(int width, int height, bool isfullScreen);
  void release();
  jobject _callback = nullptr;
};
}  // namespace codec